home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / RCSC.ZIP / LIB51 / ITOO.C < prev    next >
Text File  |  1997-01-12  |  563b  |  23 lines

  1. /*
  2. ** itoo -- converts nbr to octal string of length sz
  3. **         right adjusted and blank filled, returns str
  4. **
  5. **        if sz > 0 terminate with null byte
  6. **        if sz = 0 find end of string
  7. **        if sz < 0 use last byte for data
  8. */
  9. itoo(nbr, str, sz)  int nbr;  char str[];  int sz;  {
  10.   int digit;
  11.   if(sz>0) str[--sz]=0;
  12.   else if(sz<0) sz = -sz;
  13.   else while(str[sz]!=0) ++sz;
  14.   while(sz) {
  15.     digit=nbr&7; nbr=(nbr>>3)&8191;
  16.     str[--sz]=digit+48;
  17.     if(nbr==0) break;
  18.     }
  19.   while(sz) str[--sz]=' ';
  20.   return str;
  21.   }
  22.  
  23.